package com.leyou.order.controller;

import com.leyou.item.entity.Evaluate;
import com.leyou.order.service.EvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class EvaluateController {
    @Autowired
    private EvaluateService evaluateService;
    /**
     * 添加评价
     */
    @PostMapping("/order/evaluate/insert")
    public ResponseEntity<Void> insertEvaluate(Evaluate evaluate){
        evaluateService.insertEvaluate(evaluate);
        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }
    /**
     * 批量添加评价
     */
    @PostMapping("/order/evaluate/insert/list")
    public ResponseEntity<Void> insertEvaluateList(@RequestBody List<Evaluate> evaluateList){
        evaluateService.insertEvaluateList(evaluateList);
        return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
    }
    /**
     * 显示商品评价
     */
    @GetMapping("/order/evaluate/display")
    public ResponseEntity<List<Evaluate>> queryEvaluateListBySkuId(Long id){
        List<Evaluate> evaluateList =  evaluateService.queryEvaluateListBySkuId(id);
        return ResponseEntity.ok(evaluateList);
    }
}
